﻿

namespace PatentFee.Bussines
{
    using System.Data.Entity;
    using PatentFee.Entity;
    using System.Data.Entity.ModelConfiguration.Conventions;
    using System.ComponentModel.DataAnnotations.Schema;

    /// <summary>
    /// 上下文。
    /// </summary>
    public class PatentFeeDbContext : DbContext
    {
        public DbSet<AnnualFeeInfo> AnnualFeeInfos { get; set; }

        public DbSet<ApplicationFeeInfo> ApplicationFeeInfos { get; set; }

        public DbSet<NeedPayFeeInfo> NeedPayFeeInfos { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

            #region AnnualFeeInfo Configuration

            modelBuilder.Entity<AnnualFeeInfo>().HasKey(t => t.Id);
            modelBuilder.Entity<AnnualFeeInfo>().Property(t => t.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            #endregion

            #region ApplicationFeeInfo Configuration

            modelBuilder.Entity<ApplicationFeeInfo>().HasKey(t => t.Id).Property(t => t.Id).HasDatabaseGeneratedOption(
                DatabaseGeneratedOption.Identity);

            #endregion

            #region NeedPayFeeInfo Configuration

            modelBuilder.Entity<NeedPayFeeInfo>().HasKey(t => t.Id).Property(t => t.Id).HasDatabaseGeneratedOption(
                DatabaseGeneratedOption.Identity);

            #endregion
        }

    }
}
